package co.edu.unal.satacredito.rest.resources.files;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import co.edu.unal.satacredito.rest.activities.files.HeaderFileActivity;
import co.edu.unal.satacredito.rest.activities.visa.SimulateOrderActivity;
import co.edu.unal.satacredito.rest.domain.files.HeaderFile;
import co.edu.unal.satacredito.rest.representations.Representation;
import co.edu.unal.satacredito.rest.representations.RestUri;
import co.edu.unal.satacredito.rest.representations.files.HeaderFileRepresentation;
import co.edu.unal.satacredito.rest.representations.visa.CreditCardTransactionRepresentation;

@Path("/headerFile/")
public class HeaderFileResource {

	public HeaderFileResource() {
	}

	private @Context
	UriInfo uriInfo;

	@POST
	@Consumes(Representation.SATACREDITO_MEDIA_TYPE)
	// @Produces(Representation.VISA_MEDIA_TYPE)
	public Response headerFile(HeaderFile headerFile) {
		try {
			String responseRepresentation = new HeaderFileActivity().persist(
					headerFile, new RestUri(uriInfo.getRequestUri()));
			return Response.ok().entity(responseRepresentation).build();
		} catch (Exception ex) {
			ex.printStackTrace();
			return Response.serverError().build();
		}
	}

	@GET
	@Produces(Representation.SATACREDITO_MEDIA_TYPE)
	public Response check() {

		HeaderFile headerFile = new HeaderFile();
		headerFile.setBrandId("dsff");
		headerFile.setEstablishmentId("sdfdf");

		HeaderFileRepresentation headerfileRepr = new HeaderFileRepresentation(
				headerFile);

		return Response.ok().entity(headerfileRepr).build();
	}
}
